﻿import QtQuick 2.0

Rectangle {
    width: 1000
    height: 750
    id:itemPictureViewer
    property var onClose: function(){}
    property var _data:[]
    property int _index: 0
    property var show: function(){
        _apply(_index)
    }
    property var addPicture: function(p,t){
        var i = {};
        i.pic = "file:///" + p;
        i.text = t;
        _data.push(i);
    }
    property var clearPicture: function(){
        _data = [];
        _index = 0;
    }
    property var _apply: function(i){
        var it = _data[i]
        pictureViewerImage.source = it.pic
        pictureViewerText.text = it.text
    }
    property var _next: function(){
        if(_index < _data.length - 1){
            _index++;
            _apply(_index)
        }
    }
    property var _prev: function(){
        if(_index > 0){
            _index--;
            _apply(_index)
        }
    }

    MouseArea{
        anchors.fill: parent
    }

    Image{
//        width: parent.width
//        height: 600
//        anchors.top: pate
        anchors.fill: parent
        source: "file:///"
        id:pictureViewerImage
    }

    APPCloseMenu{
        anchors.top: parent.top
        anchors.topMargin: 16
        width: 30
        height: 30
        anchors.right: parent.right
        anchors.rightMargin: 16
        onClose:{
             itemPictureViewer.visible = false
            itemPictureViewer.onClose()
        }
    }
    Text{
        Rectangle {
            anchors.fill: parent
            color:"#282828"
            opacity: 0.6
            z:-1
        }
        id:pictureViewerText
        anchors.bottom: parent.bottom
        width: parent.width
        wrapMode: Text.WrapAnywhere
        font.family: "黑体"
        font.pixelSize: 24
        lineHeight: 1.5
        color: "#FFFFFF"
        text: ""
    }

    Image {
       id: prevImageItem
       source: "./切图/箭头/prev.png"// This is available in all editors.
       anchors.verticalCenter: parent.verticalCenter
       anchors.left: parent.left
       anchors.leftMargin: 20
       width: 40
       height: 80
       rotation: 180
        MouseArea
        {
            anchors.fill: parent
            onClicked:
            {
                itemPictureViewer._prev()
            }
        }
    }
    Image {
       id: nextImageItem
       source: "./切图/箭头/prev.png"
       anchors.verticalCenter: parent.verticalCenter
       anchors.right: parent.right
       anchors.rightMargin: 20
       width: 40
       height: 80
        MouseArea
        {
            anchors.fill: parent
            onClicked:
            {
                itemPictureViewer._next()
            }
        }
    }
}

